package com.itlong.cloud.operate.service.impl;

import com.itlong.cloud.POJO.DTO.operate.OperateAmountChangeGetPageDTO;
import com.itlong.cloud.POJO.VO.operate.OperateAmountChangeGetPageVO;
import com.itlong.cloud.operate.dao.IOperateAmountChangeDao;
import com.itlong.cloud.operate.service.IOperateAmountChangeService;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      运营-资金变动明细服务接口实现类
 * <desc/>
 *
 * @createDate 2018/09/21
 */
@Service
public class OperateAmountChangeServiceImpl implements IOperateAmountChangeService {

    @Autowired
    private IOperateAmountChangeDao iOperateAmountChangeDao;

    /**
     * <desc>
     *      分页获取资金变动明细
     * </desc>
     *
     * @param operateAmountChangeGetPageDTO 资金变动明细列表查询DTO
     * @return 分页结果
     * @author wangzhi
     * @createDate 2018/09/21
     */
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Page<OperateAmountChangeGetPageVO> getPage(OperateAmountChangeGetPageDTO operateAmountChangeGetPageDTO) throws Exception {
        Map<String,Object> params = SqlUtil.convertBeanToMapParams(operateAmountChangeGetPageDTO);
        Page<OperateAmountChangeGetPageVO> page = new Page<>();
        page.getPage().setPageSize(operateAmountChangeGetPageDTO.getPageSize());
        page.getPage().setCurrentPage(operateAmountChangeGetPageDTO.getCurrentPage());
        params.put("startSlip", page.getPage().getStartSlip());
        params.put("pageSize", page.getPage().getPageSize());
        List<OperateAmountChangeGetPageVO> operateGetProjectFinancePageVOS = iOperateAmountChangeDao.getAmountChangePage(params);
        page.setRows(operateGetProjectFinancePageVOS,iOperateAmountChangeDao.getAmountChangeRecordCount(params));
        return page;
    }

    /**
     * <desc>
     *      获取所有资金变动明细列表
     * </desc>
     *
     * @param operateAmountChangeGetPageDTO 资金变动明细列表查询DTO
     * @return 结果集
     * @author wangzhi
     * @createDate 2018/09/21
     */
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<OperateAmountChangeGetPageVO> getAllAmountChangeList(OperateAmountChangeGetPageDTO operateAmountChangeGetPageDTO) throws Exception {
        Map<String,Object> params = SqlUtil.convertBeanToMapParams(operateAmountChangeGetPageDTO);
        return iOperateAmountChangeDao.getAllAmountChangeList(params);
    }
}
